package mysynchronized;
//3个窗口卖100张票
public class MySynchronized extends Thread{
    static  int ticket=0;

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
          synchronized (MySynchronized.class) {
                if (ticket<100){
                    ticket++;
                    System.out.println(getName() + "第" + ticket + "张票");
                }
            }
        }
    }
}
